package com.luych.toolbox.data.service.controller;

import com.luych.toolbox.common.enums.DataSourceStatus;
import com.luych.toolbox.data.service.service.DataStatsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "数据应用统计")
@RestController
@RequestMapping("/stats")
public class DataStatsController {

    private final DataStatsService dataStatsService;

    @Autowired
    public DataStatsController(DataStatsService dataStatsService) {
        this.dataStatsService = dataStatsService;
    }

    @ApiOperation("按状态统计数据源个数")
    @GetMapping("/count-data-source-by-status")
    public Map<DataSourceStatus, Long> countDataSourceByStatus() {
        return dataStatsService.countDataSourceByStatus();
    }

    @ApiOperation("统计数据源个数")
    @GetMapping("/count-data-source")
    public Long countDataSource() {
        return dataStatsService.countDataSource();
    }

    @ApiOperation("统计数据项目个数")
    @GetMapping("/count-data-project")
    public Long countDataProject() {
        return dataStatsService.countDataProject();
    }

    @ApiOperation("统计数据代理个数")
    @GetMapping("/count-data-agent")
    public Long countDataAgent() {
        return dataStatsService.countDataAgent();
    }

    @ApiOperation("统计备份计划个数")
    @GetMapping("/count-data-backup-plan")
    public Long countDataBackupPlan() {
        return dataStatsService.countDataBackupPlan();
    }

    @ApiOperation("统计备份任务个数")
    @GetMapping("/count-data-backup-history")
    public Long countDataBackupHistory() {
        return dataStatsService.countDataBackupHistory();
    }

    @ApiOperation("统计恢复任务个数")
    @GetMapping("/count-data-recovery-history")
    public Long countDataRecoveryHistory() {
        return dataStatsService.countDataRecoveryHistory();
    }

    @ApiOperation("统计对比计划个数")
    @GetMapping("/count-data-compare-plan")
    public Long countComparePlan() {
        return dataStatsService.countComparePlan();
    }

    @ApiOperation("统计对比任务个数")
    @GetMapping("/count-data-compare-history")
    public Long countCompareHistory() {
        return dataStatsService.countCompareHistory();
    }

    @ApiOperation("统计对比任务个数")
    @GetMapping("/sum-data-task-by-day")
    public Map<String, Long[]> sumDataTaskByDay() {
        return dataStatsService.sumDataTaskByDay();
    }
}
